import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    isLogin: 1,
    wxInfo: {
      wxAppId: "",
      wxTimestamp: "",
      wxNonceStr: "",
      wxSignature: ""
    },
    sjListInfo: "",
    logPhoneNum: "",
    submitMsg: ""
  },
  mutations: {
    changeLogin(state, status) {
      state.isLogin = status;
    },
    setWxInfo(state, data) {
      state.wxInfo.wxAppId = data.wxAppId;
      state.wxInfo.wxTimestamp = data.wxTimestamp;
      state.wxInfo.wxNonceStr = data.wxNonceStr;
      state.wxInfo.wxSignature = data.wxSignature;
    },
    setSjInfo(state, data) {
      state.sjListInfo = data;
    },
    setPhoneNum(state, data) {
      state.logPhoneNum = data;
    },
    setSubmitMsg(state, data) {
      state.submitMsg = data;
    }
  },
  actions: {
    loginAction({ commit }, status) {
      commit("changeLogin", status);
    },
    WxInfoAction({ commit }, data) {
      commit("setWxInfo", data);
    },
    sjInfoAction({ commit }, data) {
      commit("setSjInfo", data);
    },
    setPhoneNum({ commit }, data) {
      commit("setPhoneNum", data);
    },
    setSubmitMsg({ commit }, data) {
      commit("setSubmitMsg", data);
    }
  }
});
